package cn.ekuma.epos.datalogic.define.dao;

import com.openbravo.bean.AppUserState;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.serialize.DataRead;
import com.openbravo.data.loader.serialize.DataWrite;
import com.openbravo.data.loader.serialize.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.table.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;
import e.odbo.data.dao.BaseDAO;

public class AppUserStateDAO extends BaseDAO<AppUserState>{

	public AppUserStateDAO(I_Session s) {
		super(s);
	}

	@Override
	public TableDefinition getTable() {
		return new TableDefinition(
                "USERSTATE",
                new Field[]{
                     new Field("USERID",Datas.STRING,Formats.STRING),
                     new Field("LASTLOGINDATE",Datas.TIMESTAMP,Formats.TIMESTAMP),
                     new Field("LOGINADDR",Datas.STRING,Formats.STRING)
                    },
                new int[]{0});
	}


	@Override
	public Class getSuportClass() {
		return AppUserState.class;
	}

	@Override
	public AppUserState readValues(DataRead dr,AppUserState obj) throws BasicException {
		if(obj==null)
		   obj=new AppUserState();
		obj.setUserID(dr.getString(1));
		obj.setLoginTime(dr.getTimestamp(2));
		obj.setLoginAddr(dr.getString(3));
		return obj;
	}

	@Override
	public void writeInsertValues(DataWrite dp, AppUserState obj)
			throws BasicException {
		dp.setString(1,obj.getUserID());
		dp.setTimestamp(2,obj.getLoginTime());
		dp.setString(3,obj.getLoginAddr());
	}
}
